<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="common/common_head :: commonHead('系统日志管理')"></head>
</head>
<body>
<div class="x-body">
    <form class="layui-form layui-form-pane" style="margin-left: 20px;">
        <div style="width:100%;height:400px;overflow: auto;">
            <div class="layui-form-item">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                    <legend style="font-size:16px;">任务信息</legend>
                </fieldset>
            </div>
            <div class="layui-form-item">
                <label for="jobName" class="layui-form-label">
                    <span class="x-red">*</span>任务名称
                </label>
                <div class="layui-input-block">
                    <input type="hidden" id="id" name="id" th:value="${job?.id}"/>
                    <input type="text" id="jobName" name="jobName" lay-verify="jobName"
                           autocomplete="off" class="layui-input" th:value="${job?.jobName}"/>
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span><span id="ums">名称必填</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="cron" class="layui-form-label">
                    <span class="x-red">*</span>表达式
                </label>
                <div class="layui-input-block">
                    <input type="text" id="cron" name="cron" lay-verify="cron" autocomplete="off"
                           class="layui-input" th:value="${job?.cron}"/>
                </div>
                <div id="ms" class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span><a href="http://cron.qqe2.com/" target="_blank">获取表达式</a>
                </div>
            </div>
            <!--<div class="layui-form-item">
                <label for="status" class="layui-form-label">
                    <span class="x-red">*</span>状态
                </label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="status" id="status" lay-skin="switch"
                           lay-text="启用|停用" lay-filter="statusDemo"
                           th:attr="checked=${(job?.status == null or job?.status == 1) ? 'true' : 'false'}"/>
                </div>
            </div>-->
            <div class="layui-form-item">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                    <legend style="font-size:16px;">执行类要实现Job</legend>
                </fieldset>
            </div>
            <div class="layui-form-item">
                <label for="clazzPath" class="layui-form-label">
                    <span class="x-red">*</span>任务执行类
                </label>
                <div class="layui-input-block">
                    <input type="text" id="clazzPath" name="clazzPath" lay-verify="clazzPath"
                           autocomplete="off" class="layui-input" th:value="${job?.clazzPath}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="jobDesc" class="layui-form-label">
                    <span class="x-red">*</span>任务描述
                </label>
                <div class="layui-input-block">
                    <input type="text" id="jobDesc" name="jobDesc" lay-verify="jobDesc" autocomplete="off"
                           class="layui-input" th:value="${job?.jobDesc}"/>
                </div>
            </div>
            <div style="height: 60px"></div>
        </div>
        <span th:if="${param.detail == null}">
            <div style="width: 100%;height: 55px;background-color: white;border-top:1px solid #e6e6e6;
                position: fixed;bottom: 1px;margin-left:-20px;">
                <div class="layui-form-item" style=" float: right;margin-right: 30px;margin-top: 8px">
                    <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="x">
                        保存
                    </button>
                    <button class="layui-btn layui-btn-primary" id="close">
                        取消
                    </button>
                </div>
            </div>
        </span>
    </form>
</div>
<script type="text/javascript" th:inline="javascript">/*<![CDATA[*/
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form , layer = layui.layer;

        //自定义验证规则
        form.verify({
            jobName: function (value) {
                if (value.trim() == "") {
                    return "任务名称不能为空";
                }
            },
            cron: function (value) {
                if (value.trim() == "") {
                    return "表达式不能为空";
                }
            },
            clazzPath: function (value) {
                if (value.trim() == "") {
                    return "执行类不能为空";
                }
            }
        });

        $('#close').click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
        //监听提交
        form.on('submit(add)', function (data) {
            var url =  /*[[@{/system/job/save}]]*/ "/system/job/save";
            layerAjax(url, data.field, 'jobList');
            return false;
        });
        form.render();
    });
/*]]>*/</script>
</body>
</html>